package com.example.cloudtrade;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class ProductDetailActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_product_detail);

        // 初始化视图
        ImageView ivBack = findViewById(R.id.ivBack);
        TextView tvTitle = findViewById(R.id.tvTitle);
        TextView tvPrice = findViewById(R.id.tvPrice);
        TextView tvPublishDate = findViewById(R.id.tvPublishDate);
        TextView tvDescription = findViewById(R.id.tvDescription);

        // 接收传递参数
        Intent intent = getIntent();
        String title = intent.getStringExtra("title");
        String price = intent.getStringExtra("price");
        String publishDate = intent.getStringExtra("publishDate");

        // 设置数据
        tvTitle.setText(title);
        tvPrice.setText(String.format("¥%s", price));
        tvPublishDate.setText(String.format("发布时间：%s", publishDate));

        // 设置返回按钮点击事件
        ivBack.setOnClickListener(v -> finish());
    }
    }